import { Component, OnInit } from '@angular/core';
import { NavParams } from '@ionic/angular';
import { CacheService } from '@services/cache.service';
import { ActivatedRoute } from '@angular/router';


@Component({
  selector: 'alarm-report',
  templateUrl: 'alarm-report.html',
  styleUrls: ['alarm-report.scss'],
})
export class AlarmReportPage implements OnInit {
  type;                  // 判断是集团还是项目
  projectId;             // 项目ID
  state = 'alarmCount';  // 默认显示告警统计页
  functionList = [{ functionCode: 'alarmCount', functionName: '告警统计' }, { functionCode: 'alarmDeal', functionName: '告警处理' }];

  constructor(
    private cache: CacheService,
    // private navParams: NavParams,
    private activatedRoute: ActivatedRoute
  ) {
    this.activatedRoute.queryParams.subscribe(params => {
      this.type = params.page;
      this.projectId = this.cache.currentProject.projectId ? this.cache.currentProject.projectId : params.projectId;
    });
  }

  ngOnInit() {
    console.log(this.type);
  }

  // 页面切换
  changeAlarmTab(data) {
    this.state = data;
  }

}
